package org.example.skytool.security;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

/**
 * @author 22449
 */
@Component
@Slf4j
public class StopWatchUtil {

    private ThreadLocal<StopWatch> threadLocal = new ThreadLocal<>();
    public void start(){
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        threadLocal.set(stopWatch);
    }

    public void stop(){
        StopWatch stopWatch = threadLocal.get();
        stopWatch.stop();
        log.info("执行了" + stopWatch.getTotalTimeSeconds() + "s");
    }

}
